#ifndef POSTDATA_H
#define POSTDATA_H
//
#include <QtCore>
#include <QByteArray>
//
class PostData : public QByteArray
{
//	Q_OBJECT
public:
//	void appendBinaryData(QByteArray data, QString contentType, QString field, QString fileName);
	PostData( int boundaryLength = 70);
	PostData( QString boundary_ );

	inline void setBoundary(const QString &value) { boundary = value; }
	inline QString getBoundary() { return boundary; }
	void finalize();
	void appendBinaryField(const QString &field, const QString &fileName, const QByteArray &data);
	void appendBinaryField(const QString &field, const QString &fileName, const QString &ContentType, const QByteArray &data);
	void appendTextField(const QString &field, const QString &value);
	void appendTextField(const QString &field, const int value);

	QString genBoundary(int length);
private:
	QString boundary;
	inline QString textPostData();
	inline QString binPostData();
	inline QString binPostDataContentType();
	bool finalized;
	struct HeadersType
	{
		QString ContentDisposition;
		QString FieldName;
		QString FieldValue;
		QString FileName;
		QString ContentEncoding; // Currently - binary
		QString ContentType;
		QString EndField;
	} const Headers;
	inline HeadersType HT();
	void initArray();

};
#endif
